package com.jiajia.study.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Title: RabbitDelayListener
 * @Author zjj
 * @Package com.jiajia.study.listener
 * @Date 2024/3/11 13:50
 * @description:
 */

@Component
@Slf4j
public class RabbitDelayListener {

    @RabbitListener(queues = "delay.queue.delay")
    public void receive(Message message){
        byte[] body = message.getBody();
        String msg = new String(body);
        log.info("receive message : {},time is :{}",msg,new Date());

    }

    @RabbitListener(queues = {"delay.queue.v2"})
    public void receiveDelay(Message message){
        byte[] body = message.getBody();
        String msg = new String(body);

        log.info("receive delay message ,the message is :{},time is : {}",msg,new Date());
    }
}
